package cn.parus.commons.common.Log.config;

import cn.parus.commons.common.Log.aspect.LogAspect;
import cn.parus.commons.common.Log.dao.Repsitory.LogRepository;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Title: LoggingAutoConfiguration
 * @Author 潘春兰
 * @Package cn.parus.commons.common.Log.config
 * @Date 2025/3/28 20:42
 * @description: TODO 自动配置类，使其在其他模块中自动启用
 * @Version:
 */
@Configuration
@ConditionalOnWebApplication
@ConditionalOnClass(name="org.aspectj.lang.ProceedingJoinPoint") //确保Aspect可用
@EnableConfigurationProperties(LoggingProperties.class)
public class LoggingAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public LogAspect logAspect(LogRepository logRepository,LoggingProperties loggingProperties){
        return new LogAspect(logRepository,loggingProperties);
    }


}
